package homework.work4;

import java.util.Objects;

public class Teacher implements Cloneable {
    int age;
    String name;


    //重写equals和hashcode
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Teacher teacher = (Teacher) o;
        return age == teacher.age && Objects.equals(name, teacher.name);
    }
    @Override
    public int hashCode() {
        return Objects.hash(age, name);
    }

    @Override
    public Teacher clone() throws CloneNotSupportedException {
        Teacher cloneTeacher = (Teacher) super.clone();
        return cloneTeacher;
    }

    //构造器
    public Teacher() {
    }

    public Teacher(int age, String name) {
        this.age = age;
        this.name = name;
    }
}
